//
//  GonggaoDetailVC.m
//  SSC
//
//  Created by 红沙尘 on 17/6/10.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "GonggaoDetailVC.h"

@interface GonggaoDetailVC ()<UIWebViewDelegate>
{
    __weak IBOutlet UILabel *titleLabel;
    __weak IBOutlet UILabel *dateLabel;
    __weak IBOutlet UITextView *contentView;
    
    __weak IBOutlet UIWebView *myWebView;
    NSDictionary *_dataDict;
}

@property (nonatomic, copy) NSDictionary *dataDict;

@end

@implementation GonggaoDetailVC

- (id)initWithDict:(NSDictionary *)dict {
    self = [super init];
    
    if (self) {
        _dataDict = [dict copy];
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitle:@"公告详情"];
    myWebView.delegate = self;
    
    myWebView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        
        WeakSelf;
        NSString *url = weakSelf.dataDict[@"view"];
        
        [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    }];
    
    [myWebView.scrollView.mj_header beginRefreshing];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [myWebView.scrollView.mj_header endRefreshing];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [myWebView.scrollView.mj_header endRefreshing];
}

- (void)setupData {
    
    
}

- (void)setupUI {
    
    titleLabel.text  = _dataDict[@"title"];
    dateLabel.text   = _dataDict[@"time"];
    contentView.text = _dataDict[@"content"];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
